package com.apartmentManage.service.impl;

import com.apartmentManage.dao.RoomDao;
import com.apartmentManage.entity.Room;
import com.apartmentManage.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomDao roomDao;

    /*
    * 查询所有有床位的房间
    * */
    @Override
    public List<Integer> getByApartmentNo(Integer apartmentNo) {
        List<Room> listRoom = roomDao.getByApartmentNo(apartmentNo);
        List<Integer> allRoomNo=new ArrayList<>();
        for (int i=0;i< listRoom.size();i++)
             if (listRoom.get(i).getBednumber()>0)
                allRoomNo.add(listRoom.get(i).getRoomno());
        return allRoomNo;
    }
}
